87e2ecad73b20fa22fc06038ced2da080e650c5a,plugins/git4idea/src/git4idea/branch/GitDeleteBranchOperation.java,GitDeleteBranchOperation,execute,#,61

Before Change



  public void execute() {
    Collection<GitRepository> succeeded = new ArrayList<GitRepository>();
    for (GitRepository repository : myRepositories) {
      GitSimpleEventDetector notFullyMergedDetector = new GitSimpleEventDetector(GitSimpleEventDetector.Event.BRANCH_NOT_FULLY_MERGED);
      GitCommandResult result = Git.branchDelete(repository, myBranchName, false, notFullyMergedDetector);
      if (result.success()) {
        succeeded.add(repository);
      }
      else if (notFullyMergedDetector.hasHappened()) {
        Collection<GitRepository> remainingRepos = filterOut(myRepositories, succeeded);
        boolean forceDelete = showNotFullyMergedDialog(myBranchName, remainingRepos);
        if (forceDelete) {
          GitCompoundResult compoundResult = forceDelete(myBranchName, remainingRepos);
          if (compoundResult.totalSuccess()) {
            break;
          }
          else {
            notifyError(succeeded, compoundResult);
            return;
          }
        }
        else {
          if (succeeded.isEmpty()) {
            GitMultiRootOperationExecutor
              .showFatalError(getErrorTitle(), "The branch is not fully merged to the current branch.", myProject);
          }
          else {
            StringBuilder message = new StringBuilder();
            message.append("Successfully removed in ").append(GitMultiRootOperationExecutor.joinRepositoryUrls(succeeded, "<br/>"))
              .append("The branch is not fully merged to the current branch in other repositories.");
            GitMultiRootOperationExecutor.showFatalError(getErrorTitle() + " in some repositories", message.toString(), myProject);
          }
          return;
        }
      }
      else {
        GitMultiRootOperationExecutor.showFatalError(getErrorTitle(), result.getErrorOutputAsHtmlString(), myProject);
        return;
      }
    }

After Change


  @Override
  public void execute() {
    boolean fatalErrorHappened = false;
    while (hasMoreRepositories() && !fatalErrorHappened) {
      final GitRepository repository = next();

      GitSimpleEventDetector notFullyMergedDetector = new GitSimpleEventDetector(GitSimpleEventDetector.Event.BRANCH_NOT_FULLY_MERGED);
      GitCommandResult result = Git.branchDelete(repository, myBranchName, false, notFullyMergedDetector);

      if (result.success()) {
        refresh(repository);
        markSuccessful(repository);
      }
      else if (notFullyMergedDetector.hasHappened()) {
        Collection<GitRepository> remainingRepositories = getRemainingRepositories();
        boolean forceDelete = showNotFullyMergedDialog(myBranchName, remainingRepositories);
        if (forceDelete) {
          GitCompoundResult compoundResult = forceDelete(myBranchName, remainingRepositories);
          if (compoundResult.totalSuccess()) {
            GitRepository[] remainingRepositoriesArray = ArrayUtil.toObjectArray(remainingRepositories, GitRepository.class);
            markSuccessful(remainingRepositoriesArray);
            refresh(remainingRepositoriesArray);
          }
          else {
            fatalError(getErrorTitle(), compoundResult.getErrorOutputWithReposIndication());
            return;
          }
        }
        else {
          fatalError(getErrorTitle(), "This branch is not fully merged to " + myCurrentBranch);
          fatalErrorHappened = true;
        }
      }
      else {
        fatalError(getErrorTitle(), result.getErrorOutputAsJoinedString());
        fatalErrorHappened = true;
      }
    }